package com.howells.time.module.account.presenter;

import com.howells.time.base.http.HttpURL;
import com.howells.time.base.http.HttpUtils;
import com.howells.time.base.http.JsonCallback;
import com.howells.time.module.account.view.AccountView;
import com.orhanobut.logger.Logger;

import java.util.Map;

import okhttp3.Call;

/**
 * Created by Administrator on 2016.5.8.
 */
public class AccountPresenterImp implements AccountPresenter {

    private AccountView accountView;

    public AccountPresenterImp(AccountView accountView) {
        this.accountView = accountView;
    }

    @Override
    public void signout() {
        HttpUtils.Get(HttpURL.SignOutApi.toString(),new  JsonCallback(){

            @Override
            public void onError(Call call, Exception e,int id) {
                Logger.d(e);
                accountView.resultMsg("网络异常");
                accountView.logoutsuccess();
            }

            @Override
            public void onResponse(Map<String, Object> response,int id) {
                if(response.get("success").equals("0")){
                    accountView.logoutsuccess();
                }else {
                    Logger.d(response);
                    accountView.resultMsg(response.toString());
                    accountView.logoutsuccess();
                }
            }
        });
    }
}
